<?php
/**
 * 直播相关
 * Create by PhpStorm
 * User: lijia
 * Data: 2021/1/20
 * Time: 14:23
 */

namespace app\api\controller;


use app\api\business\RedEnvelopeBus;

class Live extends UserCommon
{
    public function __construct(){
        parent::__construct();
    }


    /**
     * 领取红包
     */
    public function redEnvelope()
    {
        $data = input('param.','','trim');
        try{
            $res = (new RedEnvelopeBus())->redEnvelope($data);
            if ($res){
                return resJson(200,'领取成功');
            }else{
                return resJson(0,'领取失败');
            }
        } catch (\Exception $e){
            return resJson($e->getCode(),$e->getMessage());
        }
    }


    /**
     * 判断是否可以领取红包
     */
    public function checkEnvelope()
    {
        $res = (new RedEnvelopeBus())->checkEnvelope();
        return resJson(200,'',$res);
    }


    /**
     * 获取问题列表
     */
    public function getQua()
    {
        $list = (new RedEnvelopeBus())->getQua();
        return resJson(200,'ok',$list);
    }

    /**
     * 检查今日是否可竞猜答题
     */
    public function checkQa()
    {
        $data = (new RedEnvelopeBus())->checkQa();
        return resJson(200,'ok',$data);
    }


    /**
     * 答题
     */
    public function answer()
    {
        echo md5('kjwx');die;
        $param = input('param.', '','trim');
        $res = (new RedEnvelopeBus())->answer($param);
        return resJson(200,'ok',$res);
    }

}